#ifndef _MAT_MAP_STATE_H_
#define _MAT_MAP_STATE_H_

#include "background/bg_scene.h"
#include "script/state_holder.h"
#include "input/keyboard.h"
#include "gameflow/ui_state.h"
#include "part2d/part2d.h"

class MATMapState : public gameflow::UIState
{
public:


	struct AnimatedStamp 
	{
		AnimatedStamp() :	m_Scale(2.0f),
								m_Delay(0),
								m_Alpha(0.5f),
								m_IsFinish(true)
		{};

		void				Tick(float dt);
		void				Start(float Delay);
				

		float				m_Scale;
		float				m_Alpha;
		bool				m_IsFinish;
		float				m_Delay;
	};


	const static float			WP_SIZE;

	MATMapState(camera::FbCamera*	pCamera, const std::string& File);


	/// update the game
	virtual	bool		Tick(float dt);	
	void				GoToNextWayPoint(int PreviousLevelStatus, int Stars);

	virtual	void		MouseButtonReleased(input::Mouse::BUTTON_STATE* pKey, const math::Vec2& Pos);
	virtual void		KeyPressed(input::Keyboard::KEY* pKey);
	virtual	bool		OnEnter();

	virtual	bool		PreRender();
	virtual	bool		PostRender();


protected:

	void				AddGameState();
	void				LoadAsset();

	ui::UISprite		m_Stars[3];

	int					m_CurrentWP;	
	math::Vec2			m_Dir;
	math::Vec2			m_Pos;
	math::Vec2			m_PosTarget;

	bool				m_IsMouseUp;	
	math::Vec2			m_PreviousMousePos;
	math::Vec2			m_FirstMouseDownPos;
	math::Vec2			m_Offset;
	float				m_Scale;

	float				m_Delay;
	bool				m_CanMove;
	part2d::Part2D		m_Part2DIamHere;
	float				m_DelayGotoGame;
	math::Counter		m_CounterParticleRespawn;
	bool				m_ToSpawnParticle;
	math::Vec2			m_PosParticle;

	ui::UISprite		m_SprLockedLevel;
	bool				m_IsDebug;

	AnimatedStamp		m_AnimateInfo[3];
	int					m_AnimatedLevelIndex;
	math::Vec2			m_StarSize;
	bool				m_IsFinishAddingGameState;

	bool				m_IsLoaded;
    
};


#endif //_MAT_MAP_STATE_H_